<template>
    <div>
        <el-card class="!border-none" shadow="never">
            <el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
                <el-form-item label="用户账号">
                    <el-input
                        class="w-[280px]"
                        v-model="queryParams.account"
                        placeholder="手机号码/实名姓名"
                        clearable
                        @keyup.enter="resetPage"
                    />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="resetPage">查询</el-button>
                    <el-button @click="resetParams">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card>
        <el-card class="!border-none mt-4" shadow="never">
            <el-table size="large" v-loading="pager.loading" :data="pager.lists">
                <el-table-column label="序号" type="index" :index="indexAdd" min-width="90" />
                <el-table-column label="订单编号" min-width="180" prop="sn"/>
                <el-table-column label="下单用户" min-width="160" prop="real_name"/>
                <el-table-column label="用户账号" min-width="140" prop="account"/>
                <el-table-column label="支付金额" min-width="120" prop="actual_money"/>
                <el-table-column label="购买会员" min-width="120" prop="interests_id">
                    <template #default="{row}">
                        <span v-if="row.interests_id == 1">白银会员</span>
                        <span v-if="row.interests_id == 2">黄金会员</span>
                        <span v-if="row.interests_id == 3">钻石会员</span>
                    </template>
                </el-table-column>
                <el-table-column label="支付方式" min-width="120" prop="pay_type">
                    <template #default="{row}">
                        <span v-if="row.pay_type == 1">微信</span>
                        <span v-if="row.pay_type == 2">支付宝</span>
                    </template>
                </el-table-column>
                <el-table-column label="款项备注" min-width="180" prop="back_notice">
                    <template #default="{row}">
                        <span v-if="row.interests_id == 2">会员功能1年使用权</span>
                        <span v-else>会员功能终身使用权</span>
                        
                    </template>
                </el-table-column>
                <el-table-column label="支付时间" min-width="180" prop="update_time">
                    <template #default="{row}">
                        <span v-if="row.update_time">{{ row.update_time }}</span>
                        <span v-else>-</span>
                    </template>
                </el-table-column>
            </el-table>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
    </div>
</template>
<script lang="ts" setup name="vip">
import { usePaging } from '@/hooks/usePaging'
import { getOrderList } from '@/api/vip';

const queryParams = reactive({
    account: '',
})
const { pager, getLists, resetPage, resetParams } = usePaging({
    fetchFun: getOrderList,
    params: queryParams
})

const indexAdd = (index: number) => {
    const page = pager.page // 当前页码
    const pagesize = pager.size // 每页条数
    return index + 1 + (page - 1) * pagesize
}

getLists();
</script>